package com.tuanzi.loan.web.lazy.receipt.product;

import org.springframework.data.domain.Page;

import com.google.common.collect.Lists;
import com.tuanzi.loan.business.service.receipt.product.ReceiptProductInfoService;
import com.tuanzi.loan.core.lazy.BaseLazyDataModel;
import com.tuanzi.loan.core.util.SpringContextHolder;
import com.tuanzi.loan.core.vo.PageSearcher;
import com.tuanzi.loan.vo.request.receipt.product.ReceiptProductInfoSearchRequest;
import com.tuanzi.loan.vo.response.receipt.product.ReceiptProductInfoSearchResponse;
import com.tuanzi.server.loan_base.constant.LoanReceiptProductStatus;

/**
 * @author Ray 2017/09/21
 */
public class ReceiptProductInfoLazyDataModel extends BaseLazyDataModel<ReceiptProductInfoSearchRequest, ReceiptProductInfoSearchResponse> {

	private static final long serialVersionUID = -4670419347550704982L;

	private ReceiptProductInfoService receiptProductInfoService = SpringContextHolder.getBean(ReceiptProductInfoService.class);

	public ReceiptProductInfoLazyDataModel(ReceiptProductInfoSearchRequest request) {
		super(request);
	}

	@Override
	protected Page<ReceiptProductInfoSearchResponse> doLoad(PageSearcher<ReceiptProductInfoSearchRequest> pageSearcher) {
		pageSearcher.getSearchCondition().setLimitStatus(Lists.newArrayList(LoanReceiptProductStatus.OFFLINE.getStatus(), LoanReceiptProductStatus.ONLINE.getStatus()));
		return receiptProductInfoService.list(pageSearcher);
	}

}
